/*
 * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 *
 * This code is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License version 2 only, as
 * published by the Free Software Foundation.
 *
 * This code is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 * version 2 for more details (a copy is included in the LICENSE file that
 * accompanied this code).
 *
 * You should have received a copy of the GNU General Public License version
 * 2 along with this work; if not, write to the Free Software Foundation,
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 *
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 * or visit www.oracle.com if you need additional information or have any
 * questions.
 */
package com.oracle.max.vm.ext.vma.store.txt;

import com.oracle.max.vm.ext.vma.*;
import com.oracle.max.vm.ext.vma.store.*;

/**
 * An interface that is derived from {@link VMAdviceHandler} but is suitable for persistent storage. I.e., object
 * instances are represented by unique identifiers, class instances by their name and class loader instance id, method by
 * name, etc. This class is, therefore, completely VM independent.
 *
 * Thread, class, field  and methods are represented by <i>short forms</i> that must be declared to the store
 * implementation by, e.g. {@link #addClassShortFormDef} prior to use. No interpretation is made of the
 * value of the short form.
 *
 * Time is explicitly represented by the first argument to the advice store methods.
 *
 * Much of this class is auto-generated by {@link VMATextStoreGenerator}.
 *
 * An implementation must be thread-safe either by design or by appropriate synchronization.
 *
 */
public interface VMATextStore extends VMAStore {

    /**
     * Add a definition of a short form of a class to the store.
     * @param name full name of the class
     * @param clId object id of the defining class loader
     * @param shortName the short name to be used
     */
    void addClassShortFormDef(String name, long clId, String shortName);

    /**
     * Add a definition of a short form of a thread to the store.
     * @param name full name of the thread (may contain spaces)
     * @param shortName the short name to be used
     */
    void addThreadShortFormDef(String name, String shortName);

    /**
     * Add a definition of a short form of a field or method to the store.
     * @param name name of the field or method
     * @param shortName the short name to be used
     */
    void addMemberShortFormDef(VMATextStoreFormat.Key key, String classShortForm, String name, String shortName);

    /**
     * Record an object that was not seen by the {@link VMAdviceHandler#adviseNew} methods but was used in an operation.
     *
     * @param time
     * @param threadName irrelevant but included for consistency with other methods
     * @param bci for consistency with similar methods; ignored
     * @param objId
     * @param shortClassName
     */
    void unseenObject(long time, String threadName, int bci, long objId, String shortClassName);

// START GENERATED CODE
// EDIT AND RUN VMATextStoreGenerator.main() TO MODIFY

    void adviseBeforeGC(long time, String threadName);

    void adviseAfterGC(long time, String threadName);

    void adviseBeforeThreadStarting(long time, String threadName);

    void adviseBeforeThreadTerminating(long time, String threadName);

    void adviseBeforeReturnByThrow(long time, String threadName, int bci, long objId, int poppedFrames);

    void adviseAfterNew(long time, String threadName, int bci, long objId, String shortClassName);

    void adviseAfterNewArray(long time, String threadName, int bci, long objId, String shortClassName, int length);

    void adviseAfterMultiNewArray(long time, String threadName, int bci, long objId, String shortClassName, int length);

    void adviseBeforeIfObject(long time, String threadName, int bci, int opcode, long objId1, long objId2, int targetBci);

    void adviseBeforeIf(long time, String threadName, int bci, int opcode, int op1, int op2, int targetBci);

    void adviseAfterLoadObject(long time, String threadName, int bci, int index, long value);

    void adviseBeforeLoad(long time, String threadName, int bci, int arg1);

    void adviseBeforeGoto(long time, String threadName, int bci, int arg1);

    void adviseBeforeConstLoad(long time, String threadName, int bci, double value);

    void adviseBeforeConstLoad(long time, String threadName, int bci, float value);

    void adviseBeforeConstLoad(long time, String threadName, int bci, long value);

    void adviseBeforeConstLoadObject(long time, String threadName, int bci, long value);

    void adviseBeforeArrayLoad(long time, String threadName, int bci, long objId, int index);

    void adviseBeforeStore(long time, String threadName, int bci, int index, float value);

    void adviseBeforeStore(long time, String threadName, int bci, int index, long value);

    void adviseBeforeStore(long time, String threadName, int bci, int index, double value);

    void adviseBeforeStoreObject(long time, String threadName, int bci, int index, long value);

    void adviseBeforeArrayStore(long time, String threadName, int bci, long objId, int index, float value);

    void adviseBeforeArrayStore(long time, String threadName, int bci, long objId, int index, long value);

    void adviseBeforeArrayStoreObject(long time, String threadName, int bci, long objId, int index, long value);

    void adviseBeforeArrayStore(long time, String threadName, int bci, long objId, int index, double value);

    void adviseBeforeConversion(long time, String threadName, int bci, int arg1, double arg2);

    void adviseBeforeConversion(long time, String threadName, int bci, int arg1, long arg2);

    void adviseBeforeConversion(long time, String threadName, int bci, int arg1, float arg2);

    void adviseBeforeReturn(long time, String threadName, int bci, double value);

    void adviseBeforeReturn(long time, String threadName, int bci, float value);

    void adviseBeforeReturn(long time, String threadName, int bci);

    void adviseBeforeReturnObject(long time, String threadName, int bci, long value);

    void adviseBeforeReturn(long time, String threadName, int bci, long value);

    void adviseBeforeStackAdjust(long time, String threadName, int bci, int arg1);

    void adviseBeforeOperation(long time, String threadName, int bci, int arg1, long arg2, long arg3);

    void adviseBeforeOperation(long time, String threadName, int bci, int arg1, double arg2, double arg3);

    void adviseBeforeOperation(long time, String threadName, int bci, int arg1, float arg2, float arg3);

    void adviseBeforeGetStatic(long time, String threadName, int bci, String shortFieldName);

    void adviseBeforePutStatic(long time, String threadName, int bci, String shortFieldName, double value);

    void adviseBeforePutStatic(long time, String threadName, int bci, String shortFieldName, long value);

    void adviseBeforePutStatic(long time, String threadName, int bci, String shortFieldName, float value);

    void adviseBeforePutStaticObject(long time, String threadName, int bci, String shortFieldName, long value);

    void adviseBeforeGetField(long time, String threadName, int bci, long objId, String shortFieldName);

    void adviseBeforePutFieldObject(long time, String threadName, int bci, long objId, String shortFieldName, long value);

    void adviseBeforePutField(long time, String threadName, int bci, long objId, String shortFieldName, double value);

    void adviseBeforePutField(long time, String threadName, int bci, long objId, String shortFieldName, float value);

    void adviseBeforePutField(long time, String threadName, int bci, long objId, String shortFieldName, long value);

    void adviseBeforeInvokeVirtual(long time, String threadName, int bci, long objId, String shortMethodName);

    void adviseBeforeInvokeSpecial(long time, String threadName, int bci, long objId, String shortMethodName);

    void adviseBeforeInvokeStatic(long time, String threadName, int bci, long objId, String shortMethodName);

    void adviseBeforeInvokeInterface(long time, String threadName, int bci, long objId, String shortMethodName);

    void adviseBeforeThrow(long time, String threadName, int bci, long objId);

    void adviseBeforeCheckCast(long time, String threadName, int bci, long objId, String shortClassName);

    void adviseBeforeInstanceOf(long time, String threadName, int bci, long objId, String shortClassName);

    void adviseBeforeMonitorEnter(long time, String threadName, int bci, long objId);

    void adviseBeforeMonitorExit(long time, String threadName, int bci, long objId);

    void adviseAfterArrayLoadObject(long time, String threadName, int bci, long objId, int index, long value);

    void adviseAfterArrayLength(long time, String threadName, int bci, long objId, int length);

    void adviseAfterMethodEntry(long time, String threadName, int bci, long objId, String shortMethodName);

// END GENERATED CODE
}
